package com.sltx.service.impl;


import com.sltx.dao.aaa.ZsglMapper;
import com.sltx.service.ZsglService;
import com.sltx.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ZsglServiceImpl implements ZsglService {
    @Autowired
    private ZsglMapper zsglMapper;

    @Autowired
    WordUtil wordUtil;

    @Autowired
    DownloadUtil downloadUtil;

    @Override
    public int getNum(){
        return zsglMapper.getNum();
    }

    @Override
    public int getNumByName(PageData pd){
        return zsglMapper.getNumByName(pd);
    }

//    @Override
//    public List<Object> getXxpp(PageData pd) {
//        List<Object> result = new ArrayList<>();
//        result = zsglMapper.getXxpp(pd);
//        return  result;
//    }


    @Override
    public List<Object> getYjqyList(PageData pd){
        List<Object> result = new ArrayList<>();
        List<Map<String,Object>> list = zsglMapper.getYjqyList(pd);
        for (Map m : list){
            if (m.get("ent_gjj")== null && m.get("ent_zdqy") != null){
                m.put("ent_gjj", m.get("ent_zdqy"));
            }
            if (m.get("ent_gjj") == null && m.get("ent_zdqy")==null && m.get("ent_sfwz") != null){
                m.put("ent_gjj", "外资企业");
            }
            result.add(m);
        }

        return result;
    }

    @Override
    public int getYjqyByNameNum(PageData pd){
        return zsglMapper.getYjqyByNameNum(pd);
    }

    @Override
    public List<Object> getYjqyByName(PageData pd){
        List<Object> result = new ArrayList<>();
        List<Map<String,Object>> list = zsglMapper.getYjqyByName(pd);
        for (Map m : list){
            if("重点企业".equals(pd.get("ent_zdqy"))){
                m.put("ent_gjj",m.get("ent_zdqy"));
            }
            if ("是".equals(pd.get("ent_sfwz"))){
                m.put("ent_gjj", "外资企业");
            }
            result.add(m);
        }
        return result;
    }

    @Override
    public List<Map<Object, Object>> getByName(PageData pd){
        List<Map<Object, Object>> result = zsglMapper.getByName(pd);

        return result;
    }

    @Override
    public int insertSave(PageData pd, String[] parameterValues, HttpServletRequest request) throws Exception{
        int i = zsglMapper.getNumForName(pd);
        if (i == 0) {
            String word = wordUtil.createWord(pd,request);
            pd.put("doc",word);

            String download = downloadUtil.getDownload(pd, parameterValues, request);
            pd.put("down", download);

//            String downloadAll = downloadUtil.getDownloadAll(pd, parameterValues, request);
//            pd.put("complete",downloadAll);
            return zsglMapper.insertSave(pd);

        }else {
            return 0;
        }
    }



    @Override
    public int updateQiye(PageData pd, String[] parameterValues, HttpServletRequest request) throws Exception{

            String word = wordUtil.createWord(pd,request);
            pd.put("doc",word);

            String download = downloadUtil.getDownload(pd, parameterValues, request);
            pd.put("down", download);

            return zsglMapper.updateQiye(pd);


    }

    @Override
    public int updateState(PageData pd) throws Exception{
        return zsglMapper.updateState(pd);
    }

    //下载指标考核部门表格
    @Override
    public List<Map<String, Object>> getCyzgList(PageData pd){
        List<Map<String, Object>> result = new ArrayList();

        Map<String, Object> qtczx1 = zsglMapper.getQtczx(pd);
        if (qtczx1.get("ent_yjqydw")==null){
            qtczx1.put("ent_yjqydw","区投促中心");
            if (qtczx1.get("jf")==null){
                qtczx1.put("jf",0);
            }
            if (qtczx1.get("gxd_yjqy")==null){
                qtczx1.put("gxd_yjqy",0);
            }
            Map<String, Object> qtczx = Add_e.cyzgWczb(qtczx1, 90, 6, 8, 1300);

            result.add(qtczx);
        }else{
            Map<String, Object> qtczx = Add_e.cyzgWczb(qtczx1, 90, 6, 8, 1300);
            if (qtczx.get("jf")==null){
                qtczx1.put("jf",0);
            }
            if (qtczx.get("gxd_yjqy")==null){
                qtczx.put("gxd_yjqy",0);
            }
            result.add(qtczx);
        }


        Map<String, Object> yqgwh1 = zsglMapper.getYqgwh(pd);
        if (yqgwh1.get("ent_yjqydw") == null  ) {
            yqgwh1.put("ent_yjqydw","园区管委会");
            if (yqgwh1.get("jf")==null){
                yqgwh1.put("jf",0);
            }
            if (yqgwh1.get("gxd_yjqy")==null){
                yqgwh1.put("gxd_yjqy",0);
            }
            Map<String, Object> yqgwh = Add_e.cyzgWczb(yqgwh1, 60, 4, 7, 650);
            result.add(yqgwh);
        }else {
            Map<String, Object> yqgwh = Add_e.cyzgWczb(yqgwh1, 60, 4, 7, 650);
            if (yqgwh.get("jf")==null){
                yqgwh.put("jf",0);
            }
            if (yqgwh.get("gxd_yjqy")==null){
                yqgwh.put("gxd_yjqy",0);
            }
            result.add(yqgwh);
        }


        Map<String, Object> jrb1 = zsglMapper.getJrb(pd);
        if (jrb1.get("ent_yjqydw") == null){
            jrb1.put("ent_yjqydw","金融办");
            if (jrb1.get("jf")==null){
                jrb1.put("jf",0);
            }
            if (jrb1.get("gxd_yjqy")==null){
                jrb1.put("gxd_yjqy",0);
            }
            Map<String, Object> jrb = Add_e.cyzgWczb(jrb1, 30, 2, 1, 650);
            result.add(jrb);
        }else {
            Map<String, Object> jrb = Add_e.cyzgWczb(jrb1, 30, 2, 1, 650);
            if (jrb.get("jf")==null){
                jrb.put("jf",0);
            }
            if (jrb.get("gxd_yjqy")==null){
                jrb.put("gxd_yjqy",0);
            }
            result.add(jrb);
        }

        Map<String, Object> kw1 = zsglMapper.getKw(pd);
        if (kw1.get("ent_yjqydw")==null) {
            kw1.put("ent_yjqydw","科委");
            if (kw1.get("jf")==null){
                kw1.put("jf",0);
            }
            if (kw1.get("gxd_yjqy")==null){
                kw1.put("gxd_yjqy",0);
            }
            Map<String, Object> kw = Add_e.cyzgWczb(kw1, 30, 2, 7, 350);
            result.add(kw);
        }else {
            Map<String, Object> kw = Add_e.cyzgWczb(kw1, 30, 2, 7, 350);
            if (kw.get("jf")==null){
                kw.put("jf",0);
            }
            if (kw.get("gxd_yjqy")==null){
                kw.put("gxd_yjqy",0);
            }
            result.add(kw);
        }



        Map<String, Object> jxj1 = zsglMapper.getJxj(pd);
        if (jxj1.get("ent_yjqydw")==null) {
            jxj1.put("ent_yjqydw","经信局");
            if (jxj1.get("jf")==null){
                jxj1.put("jf",0);
            }
            if (jxj1.get("gxd_yjqy")==null){
                jxj1.put("gxd_yjqy",0);
            }
            Map<String, Object> jxj = Add_e.cyzgWczb(jxj1, 30, 2, 7, 350);
            result.add(jxj);
        }else {
            Map<String, Object> jxj = Add_e.cyzgWczb(jxj1, 30, 2, 7, 350);
            if (jxj.get("jf")==null){
                jxj.put("jf",0);
            }
            if (jxj.get("gxd_yjqy")==null){
                jxj.put("gxd_yjqy",0);
            }
            result.add(jxj);
        }

        Map<String, Object> wczx1 = zsglMapper.getWczx(pd);
        if (wczx1.get("ent_yjqydw")==null) {
            wczx1.put("ent_yjqydw","文促中心");
            if (wczx1.get("jf")==null){
                wczx1.put("jf",0);
            }
            if (wczx1.get("gxd_yjqy")==null){
                wczx1.put("gxd_yjqy",0);
            }
            Map<String, Object> wczx = Add_e.cyzgWczb(wczx1, 30, 2, 2, 350);
            result.add(wczx);
        }else {
            Map<String, Object> wczx = Add_e.cyzgWczb(wczx1, 30, 2, 2, 350);
            if (wczx.get("jf")==null){
                wczx.put("jf",0);
            }
            if (wczx.get("gxd_yjqy")==null){
                wczx.put("gxd_yjqy",0);
            }
            result.add(wczx);
        }

        Map<String, Object> swj1 = zsglMapper.getSwj(pd);
        if (swj1.get("ent_yjqydw")==null) {
            swj1.put("ent_yjqydw","商务局");
            if (swj1.get("jf")==null){
                swj1.put("jf",0);
            }
            if (swj1.get("gxd_yjqy")==null){
                swj1.put("gxd_yjqy",0);
            }
            Map<String, Object> swj = Add_e.cyzgWczb(swj1, 30, 2, 8, 350);
            result.add(swj);
        }else {
            Map<String, Object> swj = Add_e.cyzgWczb(swj1, 30, 2, 8, 350);
            if (swj.get("jf")==null){
                swj.put("jf",0);
            }
            if (swj.get("gxd_yjqy")==null){
                swj.put("gxd_yjqy",0);
            }
            result.add(swj);
        }

        int gjjNum = 0;
        int zdqyNum = 0;
        int wzqyNum = 0;
        int gjj_target = 0;
        int zd_target = 0;
        int wz_target = 0;
        int gxd_yjqy = 0;
        int gxd_target = 0;
        int jf = 0;
        int jxdf = 0;

        for (int i=0; i<result.size(); i++){
            Map map = (Map) result.get(i);
            int wz_target1 = StringToInt.getStringToInt(map.get("wz_target").toString());

            wz_target += wz_target1;
            int gjj_target1 = StringToInt.getStringToInt(map.get("gjj_target").toString());
            gjj_target+=gjj_target1;
            int zd_target1 = StringToInt.getStringToInt(map.get("zd_target").toString());
            zd_target+=zd_target1;
            int gxd_target1 = StringToInt.getStringToInt(map.get("gxd_target").toString());
            gxd_target +=gxd_target1;
            int jf1 = StringToInt.getStringToInt(map.get("jf").toString());
            jf += jf1;
            int jxdf1 = StringToInt.getStringToInt(map.get("jxdf").toString());
            jxdf += jxdf1;
            if (map.get("gxd_yjqy") != null) {
                int gxd_yjqy1 = StringToInt.getStringToInt(map.get("gxd_yjqy").toString());
                gxd_yjqy += gxd_yjqy1;
            }
            if (map.get("gjjNum")!=null) {
                int gjjNum1 = StringToInt.getStringToInt(map.get("gjjNum").toString());
                gjjNum += gjjNum1;
            }
            if (map.get("zdqyNum") !=null) {
                int zdqyNum1 = StringToInt.getStringToInt(map.get("zdqyNum").toString());
                zdqyNum += zdqyNum1;
            }
            if (map.get("wzqyNum") != null) {
                int wzqyNum1 = StringToInt.getStringToInt(map.get("wzqyNum").toString());
                wzqyNum += wzqyNum1;
            }
        }
        Map zj = new HashMap();
        zj.put("wcmb2021",0);
        zj.put("gjjNum",gjjNum);
        zj.put("zdqyNum",zdqyNum);
        zj.put("wzqyNum",wzqyNum);
        zj.put("gjj_target",gjj_target);
        zj.put("zd_target",zd_target);
        zj.put("wz_target",wz_target);
        zj.put("gxd_yjqy",gxd_yjqy);
        zj.put("gxd_target",gxd_target);
        zj.put("jf",jf);
        zj.put("jxdf",jxdf);
        zj.put("ent_yjqydw","总计");
        result.add(zj);

        Map pjz = new HashMap();
        pjz.put("wcmb2021", 0);
        pjz.put("gjjNum",gjjNum/7);
        pjz.put("zdqyNum",zdqyNum/7);
        pjz.put("wzqyNum",wzqyNum/7);
        pjz.put("gjj_target",gjj_target/7);
        pjz.put("zd_target",zd_target/7);
        pjz.put("wz_target",wz_target/7);
        pjz.put("gxd_yjqy",gxd_yjqy/7);
        pjz.put("gxd_target",gxd_target/7);
        pjz.put("jf",jf/7);
        pjz.put("jxdf",jxdf/7);
        pjz.put("ent_yjqydw","平均值");
        result.add(pjz);

        return result;
    }


    @Override
    public List<Map<String, Object>> getLhzsList(PageData pd){
        List<Map<String, Object>> result = new ArrayList();

        Map<String, Object> qfgw1 = zsglMapper.getQfgw(pd);
        if (qfgw1.get("ent_yjqydw") == null) {
            qfgw1.put("ent_yjqydw","区发改委");
            if (qfgw1.get("jf")==null){
                qfgw1.put("jf",0);
            }
            if (qfgw1.get("gxd_yjqy")==null){
                qfgw1.put("gxd_yjqy",0);
            }
            qfgw1.put("zd_target",0);
            qfgw1.put("wz_target",0);
            Map<String, Object> qfgw = Add_e.lhzsWczb(qfgw1, 10, 75);
            result.add(qfgw);
        }else {
            Map<String, Object> qfgw = Add_e.lhzsWczb(qfgw1, 10, 75);
            if (qfgw.get("jf")==null){
                qfgw.put("jf",0);
            }
            if (qfgw.get("gxd_yjqy")==null){
                qfgw.put("gxd_yjqy",0);
            }
            qfgw.put("zd_target",0);
            qfgw.put("wz_target",0);
            result.add(qfgw);
        }

        Map<String, Object> zjw1 = zsglMapper.getZjw(pd);
        if (zjw1.get("ent_yjqydw")==null) {
            zjw1.put("ent_yjqydw","住建委");
            if (zjw1.get("jf")==null){
                zjw1.put("jf",0);
            }
            if (zjw1.get("gxd_yjqy")==null){
                zjw1.put("gxd_yjqy",0);
            }
            zjw1.put("zd_target",0);
            zjw1.put("wz_target",0);
            Map<String, Object> zjw = Add_e.lhzsWczb(zjw1, 10, 75);
            result.add(zjw);
        }else {
            Map<String, Object> zjw = Add_e.lhzsWczb(zjw1, 10, 75);
            if (zjw.get("jf")==null){
                zjw.put("jf",0);
            }
            if (zjw.get("gxd_yjqy")==null){
                zjw.put("gxd_yjqy",0);
            }
            zjw.put("zd_target",0);
            zjw.put("wz_target",0);
            result.add(zjw);
        }

        Map<String, Object> cwj1 = zsglMapper.getCwj(pd);
        if (cwj1.get("ent_yjqydw")==null){
            cwj1.put("ent_yjqydw","财政局");
            if (cwj1.get("jf")==null){
                cwj1.put("jf",0);
            }
            if (cwj1.get("gxd_yjqy")==null){
                cwj1.put("gxd_yjqy",0);
            }
            cwj1.put("zd_target",0);
            cwj1.put("wz_target",0);
            Map<String, Object> cwj = Add_e.lhzsWczb(cwj1, 10, 75);
            result.add(cwj);
        }else {
            Map<String, Object> cwj = Add_e.lhzsWczb(cwj1, 10, 75);
            if (cwj.get("jf")==null){
                cwj.put("jf",0);
            }
            if (cwj.get("gxd_yjqy")==null){
                cwj.put("gxd_yjqy",0);
            }
            cwj.put("zd_target",0);
            cwj.put("wz_target",0);
            result.add(cwj);
        }

        Map<String, Object> zwfwj1 = zsglMapper.getZwfwj(pd);
        if (zwfwj1.get("ent_yjqydw")==null) {
            zwfwj1.put("ent_yjqydw","政务服务局");
            if (zwfwj1.get("jf")==null){
                zwfwj1.put("jf",0);
            }
            if (zwfwj1.get("gxd_yjqy")==null){
                zwfwj1.put("gxd_yjqy",0);
            }
            zwfwj1.put("zd_target",0);
            zwfwj1.put("wz_target",0);
            Map<String, Object> zwfwj = Add_e.lhzsWczb(zwfwj1, 10, 75);
            result.add(zwfwj);
        }else {
            Map<String, Object> zwfwj = Add_e.lhzsWczb(zwfwj1, 10, 75);
            if (zwfwj.get("jf")==null){
                zwfwj.put("jf",0);
            }
            if (zwfwj.get("gxd_yjqy")==null){
                zwfwj.put("gxd_yjqy",0);
            }
            zwfwj.put("zd_target",0);
            zwfwj.put("wz_target",0);
            result.add(zwfwj);
        }

        Map<String, Object> tyj1 = zsglMapper.getTyj(pd);
        if (tyj1.get("ent_yjqydw")==null) {
            tyj1.put("ent_yjqydw","体育局");
            if (tyj1.get("jf")==null){
                tyj1.put("jf",0);
            }
            if (tyj1.get("gxd_yjqy")==null){
                tyj1.put("gxd_yjqy",0);
            }
            tyj1.put("zd_target",0);
            tyj1.put("wz_target",0);
            Map<String, Object> tyj = Add_e.lhzsWczb(tyj1, 10, 75);
            result.add(tyj);
        }else {
            Map<String, Object> tyj = Add_e.lhzsWczb(tyj1, 10, 75);
            if (tyj.get("jf")==null){
                tyj.put("jf",0);
            }
            if (tyj.get("gxd_yjqy")==null){
                tyj.put("gxd_yjqy",0);
            }
            tyj.put("zd_target",0);
            tyj.put("wz_target",0);
            result.add(tyj);
        }

        Map<String, Object> xbjsb1 = zsglMapper.getXbjsb(pd);
        if (xbjsb1.get("ent_yjqydw")==null) {
            xbjsb1.put("ent_yjqydw","西部建设办");
            if (xbjsb1.get("jf")==null){
                xbjsb1.put("jf",0);
            }
            if (xbjsb1.get("gxd_yjqy")==null){
                xbjsb1.put("gxd_yjqy",0);
            }
            xbjsb1.put("zd_target",0);
            xbjsb1.put("wz_target",0);
            Map<String, Object> xbjsb = Add_e.lhzsWczb(xbjsb1, 10, 75);
            result.add(xbjsb);
        }else {
            Map<String, Object> xbjsb = Add_e.lhzsWczb(xbjsb1, 10, 75);
            if (xbjsb.get("jf")==null){
                xbjsb.put("jf",0);
            }
            if (xbjsb.get("gxd_yjqy")==null){
                xbjsb.put("gxd_yjqy",0);
            }
            xbjsb.put("zd_target",0);
            xbjsb.put("wz_target",0);
            result.add(xbjsb);
        }

        Map<String, Object> wlj1 = zsglMapper.getWlj(pd);
        if (wlj1.get("ent_yjqydw")==null) {
            wlj1.put("ent_yjqydw","文旅局");
            if (wlj1.get("jf")==null){
                wlj1.put("jf",0);
            }
            if (wlj1.get("gxd_yjqy")==null){
                wlj1.put("gxd_yjqy",0);
            }
            wlj1.put("zd_target",0);
            wlj1.put("wz_target",0);
            Map<String, Object> wlj = Add_e.lhzsWczb(wlj1, 10, 75);
            result.add(wlj);
        }else {
            Map<String, Object> wlj = Add_e.lhzsWczb(wlj1, 10, 75);
            if (wlj.get("jf")==null){
                wlj.put("jf",0);
            }
            if (wlj.get("gxd_yjqy")==null){
                wlj.put("gxd_yjqy",0);
            }
            wlj.put("zd_target",0);
            wlj.put("wz_target",0);
            result.add(wlj);
        }

        Map<String, Object> gzgj1 = zsglMapper.getGzgj(pd);
        if (gzgj1.get("ent_yjqydw")==null) {
            gzgj1.put("ent_yjqydw","规自分局");
            if (gzgj1.get("jf")==null){
                gzgj1.put("jf",0);
            }
            if (gzgj1.get("gxd_yjqy")==null){
                gzgj1.put("gxd_yjqy",0);
            }
            gzgj1.put("zd_target",0);
            gzgj1.put("wz_target",0);
            Map<String, Object> gzgj = Add_e.lhzsWczb(gzgj1, 10, 75);
            result.add(gzgj);
        }else {
            Map<String, Object> gzgj = Add_e.lhzsWczb(gzgj1, 10, 75);
            if (gzgj.get("jf")==null){
                gzgj.put("jf",0);
            }
            if (gzgj.get("gxd_yjqy")==null){
                gzgj.put("gxd_yjqy",0);
            }
            gzgj.put("zd_target",0);
            gzgj.put("wz_target",0);
            result.add(gzgj);
        }

        Map<String, Object> gsl1 = zsglMapper.getGsl(pd);
        if (gsl1.get("ent_yjqydw")==null) {
            gsl1.put("ent_yjqydw","工商联");
            if (gsl1.get("jf")==null){
                gsl1.put("jf",0);
            }
            if (gsl1.get("gxd_yjqy")==null){
                gsl1.put("gxd_yjqy",0);
            }
            gsl1.put("zd_target",0);
            gsl1.put("wz_target",0);
            Map<String, Object> gsl = Add_e.lhzsWczb(gsl1, 10, 75);
            result.add(gsl);
        }else {
            Map<String, Object> gsl = Add_e.lhzsWczb(gsl1, 10, 75);
            if (gsl.get("jf")==null){
                gsl.put("jf",0);
            }
            if (gsl.get("gxd_yjqy")==null){
                gsl.put("gxd_yjqy",0);
            }
            gsl.put("zd_target",0);
            gsl.put("wz_target",0);
            result.add(gsl);
        }


        Map<String, Object> gzw1 = zsglMapper.getGzw(pd);
        if (gzw1.get("ent_yjqydw")==null) {
            gzw1.put("ent_yjqydw","国资委");
            if (gzw1.get("jf")==null){
                gzw1.put("jf",0);
            }
            if (gzw1.get("gxd_yjqy")==null){
                gzw1.put("gxd_yjqy",0);
            }
            gzw1.put("zd_target",0);
            gzw1.put("wz_target",0);
            Map<String, Object> gzw = Add_e.lhzsWczb(gzw1, 25, 150);
            result.add(gzw);
        }else {
            Map<String, Object> gzw = Add_e.lhzsWczb(gzw1, 25, 150);
            if (gzw.get("jf")==null){
                gzw.put("jf",0);
            }
            if (gzw.get("gxd_yjqy")==null){
                gzw.put("gxd_yjqy",0);
            }
            gzw.put("zd_target",0);
            gzw.put("wz_target",0);
            result.add(gzw);
        }

        Map<String, Object> jtzcjgb1 = zsglMapper.getJtzcjgb(pd);
        if (jtzcjgb1.get("ent_yjqydw")==null) {
            jtzcjgb1.put("ent_yjqydw","集体资产监管办");
            if (jtzcjgb1.get("jf")==null){
                jtzcjgb1.put("jf",0);
            }
            if (jtzcjgb1.get("gxd_yjqy")==null){
                jtzcjgb1.put("gxd_yjqy",0);
            }
            jtzcjgb1.put("zd_target",0);
            jtzcjgb1.put("wz_target",0);
            Map<String, Object> jtzcjgb = Add_e.lhzsWczb(jtzcjgb1, 25, 150);
            result.add(jtzcjgb);
        }else {
            Map<String, Object> jtzcjgb = Add_e.lhzsWczb(jtzcjgb1, 25, 150);
            if (jtzcjgb.get("jf")==null){
                jtzcjgb.put("jf",0);
            }
            if (jtzcjgb.get("gxd_yjqy")==null){
                jtzcjgb.put("gxd_yjqy",0);
            }
            jtzcjgb.put("zd_target",0);
            jtzcjgb.put("wz_target",0);
            result.add(jtzcjgb);
        }

        int gjjNum = 0;
        int gjj_target = 0;
        int gxd_yjqy = 0;
        int gxd_target = 0;
        int jf = 0;
        int jxdf = 0;

        for (int i=0; i<result.size(); i++){
            Object o = result.get(i);
            System.out.println("o==" +o );
            Map map = (Map) result.get(i);
            int gjj_target1 = StringToInt.getStringToInt(map.get("gjj_target").toString());
            gjj_target+=gjj_target1;
            int gxd_target1 = StringToInt.getStringToInt(map.get("gxd_target").toString());
            gxd_target +=gxd_target1;
            int jf1 = StringToInt.getStringToInt(map.get("jf").toString());
            jf += jf1;
            int jxdf1 = StringToInt.getStringToInt(map.get("jxdf").toString());
            jxdf += jxdf1;
            if ( map.get("gxd_yjqy") != null) {
                int gxd_yjqy1 = StringToInt.getStringToInt(map.get("gxd_yjqy").toString());
                gxd_yjqy += gxd_yjqy1;
            }
            if (map.get("gjjNum")!=null) {
                int gjjNum1 = StringToInt.getStringToInt(map.get("gjjNum").toString());
                gjjNum += gjjNum1;
            }
        }
        Map zj = new HashMap();
        zj.put("wcmb2021",0);
        zj.put("gjjNum",gjjNum);
        zj.put("zdqyNum",0);
        zj.put("wzqyNum",0);
        zj.put("gjj_target",gjj_target);
        zj.put("zd_target",0);
        zj.put("wz_target",0);
        zj.put("gxd_yjqy",gxd_yjqy);
        zj.put("gxd_target",gxd_target);
        zj.put("jf",jf);
        zj.put("jxdf",jxdf);
        zj.put("ent_yjqydw","总计");
        result.add(zj);

        Map pjz = new HashMap();
        pjz.put("wcmb2021", 0);
        pjz.put("gjjNum",gjjNum/11);
        pjz.put("zdqyNum",0);
        pjz.put("wzqyNum",0);
        pjz.put("gjj_target",gjj_target/11);
        pjz.put("zd_target",0);
        pjz.put("wz_target",0);
        pjz.put("gxd_yjqy",gxd_yjqy/11);
        pjz.put("gxd_target",gxd_target/11);
        pjz.put("jf",jf);
        pjz.put("jxdf",jxdf);
        pjz.put("ent_yjqydw","平均值");
        result.add(pjz);

        return result;
    }

    @Override
    public int getzbkhNum(PageData pd){
        return zsglMapper.getzbkhNum(pd);
    }

    @Override
    public List<Object> getZbkhlList(PageData pd){
        List<Object> result = new ArrayList();
        List<Map<String, Object>> list = zsglMapper.getZbkhlList(pd);

        for (Map m : list){
            /**
             * 判断查询的是什么企业类型，并把数据类型重新赋值ent_gjj
             * 如果查询 高精尖企业，则不用处理
             */
            if("重点企业".equals(pd.get("ent_zdqy"))){
                m.put("ent_gjj",m.get("ent_zdqy"));
            }
            if ("是".equals(pd.get("ent_sfwz"))){
                m.put("ent_gjj", "外资企业");
            }
            result.add(m);
        }

        return result;
    }

    @Override
    public int updateJfxx(PageData pd){
        return zsglMapper.updateJfxx(pd);
    }

    @Override
    public int getXmzlNum(PageData pd){
        return zsglMapper.getXmzlNum(pd);
    }

    @Override
    public List<Object> getXmzl(PageData pd){
        List<Object> result = new ArrayList();
        List<Map<String,Object>> list = zsglMapper.getXmzl(pd);
        for (Map m : list){
            /**
             * 判断查询的是什么企业类型，并把数据类型重新赋值ent_gjj
             * 如果查询 高精尖企业，则不用处理
             */
            if("重点企业".equals(pd.get("ent_zdqy"))){
                m.put("ent_gjj",m.get("ent_zdqy"));
            }
            if ("是".equals(pd.get("ent_sfwz"))){
                m.put("ent_gjj", "外资企业");
            }
            result.add(m);
        }
        return result;
    }

    @Override
    public List<Object> getXmzlBy(PageData pd){
        List<Object> result = new ArrayList();
        result.add(zsglMapper.getXmzlBy(pd));
        return result;
    }

    @Override
    public List<Object> getGjjListNum(){
        List<Object> result = new ArrayList();

        Map<String, Object> szcyNum = zsglMapper.getSzcyNum();
        if (szcyNum.size() >1){
            result.add(szcyNum);
        }

        Map<String, Object> xdjrNum = zsglMapper.getXdjrNum();
        if (xdjrNum.size()>1){
            result.add(xdjrNum);
        }

        Map<String, Object> xydxxjsNum = zsglMapper.getXydxxjsNum();
        if (xydxxjsNum.size()>1){
            result.add(xydxxjsNum);
        }

        Map<String, Object> kjfwNum = zsglMapper.getKjfwNum();
        if (kjfwNum.size()>1){
            result.add(kjfwNum);
        }

        Map<String, Object> swfwyNum = zsglMapper.getSwfwyNum();
        if (swfwyNum.size()>1){
            result.add(swfwyNum);
        }

        Map<String, Object> bxtyNum = zsglMapper.getBxtyNum();
        if (bxtyNum.size()>1){
            result.add(bxtyNum);
        }

        Map<String, Object> qtNum = zsglMapper.getQtNum();
        if (qtNum.size()>1){
            result.add(qtNum);
        }

//        if (szcyNum.size()==0 &&
//                xdjrNum.size()==0 &&
//                xydxxjsNum.size()==0 &&
//                kjfwNum.size()==0 &&
//                swfwyNum.size()==0 &&
//                bxtyNum.size()==0 &&
//                qtNum.size()==0){
//            szcyNum.put("name","数字创意");
//            szcyNum.put("value",0);
//            result.add(szcyNum);
//        }

        return result;
    }

    @Override
    public List<Object> getZdListNum(){
        List<Object> result = new ArrayList();
        Map<String, Object> ssqyNum = zsglMapper.getSsqyNum();
        if (ssqyNum.size()>1){
            result.add(ssqyNum);
        }

        Map<String, Object> nssNum = zsglMapper.getNssNum();
        if (nssNum.size()>1){
            result.add(nssNum);
        }

        Map<String, Object> djsNum = zsglMapper.getDjsNum();
        if (djsNum.size()>1){
            result.add(djsNum);
        }

        Map<String, Object> zdjsNum = zsglMapper.getZdjsNum();
        if (zdjsNum.size()>1){
            result.add(zdjsNum);
        }

        Map<String, Object> yxgjNum = zsglMapper.getYxgjNum();
        if (yxgjNum.size()>1){
            result.add(yxgjNum);
        }

        Map<String, Object> hyltNum = zsglMapper.getHyltNum();
        if (hyltNum.size()>1){
            result.add(hyltNum);
        }

        Map<String, Object> wzqyNum = zsglMapper.getWzqyNum();
        if (wzqyNum.size()>1){
            result.add(wzqyNum);
        }

        Map<String, Object> yqNum = zsglMapper.getYqNum();
        if (yqNum.size()>1){
            result.add(yqNum);
        }

        Map<String, Object> gqNum = zsglMapper.getGqNum();
        if (gqNum.size()>1){
            result.add(gqNum);
        }

        Map<String, Object> yzsyNum = zsglMapper.getYzsyNum();
        if (yzsyNum.size()>1){
            result.add(yzsyNum);
        }

        Map<String, Object> getqt = zsglMapper.getqt();
        if(getqt.size()>1){
            result.add(getqt);
        }


        return result;
    }

    @Override
    public List<Object> getWzListNum(){
        List<Object> result = new ArrayList();
        if (!"0".equals(zsglMapper.getWzyrdNum().get("value"))){
            result.add(zsglMapper.getWzyrdNum());
        }

        if (!"0".equals(zsglMapper.getWzwrdNum().get("value"))){
            result.add(zsglMapper.getWzwrdNum());
        }

        return result;
    }

    @Override
    public List<Object> getCyzgNum(){
        List<Object> result = new ArrayList();
        result.add(zsglMapper.getQtczxNum());
        result.add(zsglMapper.getYqgwhNum());
        result.add(zsglMapper.getJrbNum());
        result.add(zsglMapper.getKwNum());
        result.add(zsglMapper.getJxjNum());
        result.add(zsglMapper.getWczxNum());
        result.add(zsglMapper.getSwjNum());
        return result;
    }

    @Override
    public List<Object> getLhzsNum(){
        List<Object> result = new ArrayList();
        result.add(zsglMapper.getQfgwNum());
        result.add(zsglMapper.getZjwNum());
        result.add(zsglMapper.getCwjNum());
        result.add(zsglMapper.getZwfwjNum());
        result.add(zsglMapper.getTyjNum());
        result.add(zsglMapper.getXbjsbNum());
        result.add(zsglMapper.getWljNum());
        result.add(zsglMapper.getGzgjNum());
        result.add(zsglMapper.getGslNum());
        result.add(zsglMapper.getGzwNum());
        result.add(zsglMapper.getJtzcjgbNum());
        return result;
    }

    @Override
    public List<Object> getSslj(){
        List<Object> result = new ArrayList();
        result.add(zsglMapper.getSslj());
        return result;
    }




    @Override
    public String getDbxz(HttpServletRequest request) throws Exception {
        List<Map<String, Object>> dbxz = zsglMapper.getDbxz();
        List<Object> result = new ArrayList<>();
        for (int i =0; i<dbxz.size(); i++){
            if (dbxz.get(i).get("down") != null) {
                result.add(dbxz.get(i).get("down"));
            }
        }

        String downUrl = downloadUtil.getDownUrl(result, request);

        return downUrl;
    }



    @Override
    public List<Map<String,Object>> getDeptQyList(PageData pd){
        List<Map<String, Object>> deptQyList = zsglMapper.getDeptQyList(pd);
        return deptQyList;
    }
}
